package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.service.OverflowListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/overflowListGoods")
public class OverflowListGoodsController {
    @Autowired
    private OverflowListGoodsService overflowListGoodsService;

    /**
     * 保存报溢单以及报溢商品
     * @param overflowList
     * @param overflowListGoodsStr
     * @return
     */
    @PostMapping("save")
    public ServiceVO save(OverflowList overflowList, String overflowListGoodsStr){
        return overflowListGoodsService.save(overflowList,overflowListGoodsStr);
    }


    /**
     * 查询报溢单
     * @param sTime
     * @param eTime
     * @return
     */
    @PostMapping("list")
    public Map<String,Object> list(String  sTime, String  eTime){
        HashMap<String, Object> map = new HashMap<>();
        map.put("rows", overflowListGoodsService.list(sTime, eTime));
        return map;
    }

    /**
     * 根据报溢单号查询报溢商品
     * @param overflowListId
     * @return
     */
    @PostMapping("goodsList")
    public Map<String,Object> goodsList(Integer overflowListId){
        HashMap<String, Object> map = new HashMap<>();
        map.put("rows",overflowListGoodsService.goodsList(overflowListId));
        return map;
    }

}
